



#include <iostream>
#include <vector>
#include <string>
using namespace std;

class Solution
{
public:
    string removeKdigits(string num, int k)
    {
        int n = num.size();
        if (n == k)
            return "0";

        string res;
        vector<char> v;

        for (const auto& e : num)
        {
            while (k && v.size() && v.back() > e)
            {
                v.pop_back();
                --k;
            }
            v.push_back(e);
        }

        while (k > 0)
        {
            v.pop_back();
            --k;
        }

        for (int index = 0, n = v.size(); index < n;)
        {
            while (index < n && '0' == v[index])
            {
                ++index;
            }
            if (index == n)
            {
                res = "0";
                break;
            }

            while (index < n)
            {
                res += v[index++];
            }
        }

        return res;
    }

    int maxSubArray1(vector<int>& nums)
    {
        int n = nums.size();
        vector<int> dp(n, nums[0]);

        int res = nums[0];
        for (int i = 1; i < n; ++i)
        {
            dp[i] = max(nums[i], dp[i - 1] + nums[i]);
            res = max(dp[i], res);
        }

        return res;
    }

    int maxSubArray2(vector<int>& nums)
    {
        int res = nums[0], prev = 0;

        for (const auto& e : nums)
        {
            prev = max(prev + e, e);
            res = max(res, prev);
        }

        return res;
    }

    int maxSubArray3(vector<int>& nums)
    {
        int res = INT_MIN, sum = 0;

        for (const auto& e : nums)
        {
            sum += e;
            res = max(res, sum);

            if (sum < 0)
                sum = 0;
        }

        return res;
    }
};

void Test1(int cnt)
{
    if (cnt == 3)
        return;

    printf("hello world!!!\n");
    Test1(++cnt);
}

void Print(int n)
{
    if (n < 10)
    {
        printf("%d", n);
        return;
    }

    Print(n / 10);
    printf("%d", n % 10);
}

void Test2()
{
    for (int i = 1; i < 101; ++i)
    {
        printf("%-3d", i);
    }
    putchar('\n');
}

void Test3(int cnt)
{
    if (cnt > 100)
        return;

    printf("%-3d", cnt);
    Test3(++cnt);
}

int main()
{
    //Test1(0);
    Test2();
    Test3(1);

	return 0;
}